package com.jinlia.show.modules.wxapp.controller;

import com.jinlia.show.modules.base.service.WxMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信消息订阅
 */
@RestController
@RequestMapping("/message")
public class WxMessageController {

    @Autowired
    WxMessageService wxMessageService;
    /**
     * 小程序版本
     */
    @Value("${wx.version}")
    public String wxVersion;//微信版本

    /**
     * 商户确认消息
     *
     * @param id 配送单id
     * @return
     */
    @GetMapping("/confirm/order/{id}")
    public String sendConfirmOrderMsg(@PathVariable("id") Long id) {
        String s = wxMessageService.sendConfirmOrderMsg(id, wxVersion);
        return s;
    }

    /**
     * 订单配送消息
     *
     * @param id 配送单id
     * @return
     */
    @GetMapping("/order/change/{id}")
    public String sendOrderDeliverMsg(@PathVariable("id") Long id) {
        String s = wxMessageService.sendOrderDeliverMsg(id, wxVersion);
        return s;
    }
}
